package com.muyu.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName: ScheduleTask
 * @Author: Zirun.Xin
 * @Date: 2025/4/23 下午2:16
 * @Version: 1.0
 * @Description: 调度任务控制器
 */
@Slf4j
@Component
public class ScheduleTask {

    private int count = 0;

    /**
     * 调度任务（每5秒执行一次）
     */
    @Scheduled(cron = "0/5 * * * * ? ")
    public void execute() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        count ++;
        log.info("我执行{}次咯，此时时间：{}", count, sdf.format(new Date()));
    }
}
